<template>
  <div class="introduceBox">
    <div class="imgBox">
      <img :src="playlist.coverImgUrl" alt="" />
    </div>
    <div class="introduceBoxRight">
      <div class="introduceBoxTitle">
        <p class="label"></p>
        <div class="songSheetName" :title="playlist.name">
          {{ playlist.name }}
        </div>
      </div>
      <div class="userBox">
        <img class="userImg" :src="playlist.creator.avatarUrl" alt="" />
        <span class="nickname">{{ playlist.creator.nickname }}</span>
        <span class="createTime"
          >{{ playlist.createTime | fmtDate("yyyy-MM-DD") }}创建</span
        >
      </div>
      <div class="btnBox">
        <div class="playBtn" @click="songSheetPlay(playlist.tracks)">
          <i></i>
          <span>播放</span>
        </div>
        <div class="addSongSheet" @click="addMusicList(playlist.tracks)"></div>
        <div class="btnClass">
          <i>{{ playlist.subscribedCount | numChange }}</i>
        </div>
        <div class="btnClass forward">
          <i>{{ playlist.shareCount | numChange }}</i>
        </div>
        <div class="btnClass download">
          <i>下载</i>
        </div>
        <div class="btnClass comment">
          <i>{{ playlist.commentCount | numChange }}</i>
        </div>
      </div>
      <div class="labelBox">
        <span>标签：</span>
        <ul>
          <li
            class="labelItem"
            v-for="(item, index) in playlist.tags"
            :key="index"
          >
            {{ item }}
          </li>
        </ul>
      </div>
      <p :class="isOPen ? 'descriptionte' : 'description'">
        介绍：{{ playlist.description }}
      </p>
      <span class="openBtn" v-if="!isOPen" @click="isOPen = true"
        >展开<i></i
      ></span>
      <span class="PutItAwayBtn" v-if="isOPen" @click="isOPen = false"
        >收起<i></i
      ></span>
    </div>
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  props: {
    playlist: {
      type: Object,
      default: {},
    },
    resourcesId: {
      type: Number,
      default: {},
    },
  },
  data() {
    return {
      isOPen: false,
    };
  },
  filters: {
    numChange(num) {
      if (num > 99999) {
        return parseInt(num / 10000) + "万";
      } else {
        return num;
      }
    },
  },
  methods: {
    ...mapActions("musicStore", ["songSheetPlay", "addMusicList"]),
  },
};
</script>

<style lang="scss" scoped>
.introduceBox {
  width: 100%;
  display: flex;
  .imgBox {
    width: 200px;
    height: 200px;
    padding: 2px;
    border: 1px solid #ccc;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .introduceBoxRight {
    flex: 1;
    overflow: hidden;
    margin-left: 30px;
    .introduceBoxTitle {
      display: flex;
      .label {
        width: 54px;
        height: 24px;
        background: url("./../../assets/imges/btnIconTwo.png") no-repeat 0 -243px;
        margin-right: 10px;
      }
      .songSheetName {
        flex: 1;
        line-height: 24px;
        font-size: 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
    .userBox {
      display: flex;
      align-items: center;
      margin: 12px 0 20px;
      .userImg {
        width: 35px;
        height: 35px;
      }
      .nickname {
        color: #0c73c2;
        margin: 0 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .createTime {
        color: #999;
      }
    }
    .btnBox {
      .playBtn {
        background: url("./../../assets/imges/backgroundStripe.png") no-repeat 0 -387px;
        padding: 0 5px 0 0;
        height: 31px;
        display: inline-block;
        color: #fff;
        vertical-align: middle;
        cursor: pointer;
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -1622px;
          width: 20px;
          height: 18px;
          margin: 6px 2px 2px 5px;
          display: inline-block;
          vertical-align: middle;
        }
        span {
          vertical-align: middle;
        }
      }
      .addSongSheet {
        margin-right: 5px;
        line-height: 30px;
        width: 31px;
        display: inline-block;
        height: 31px;
        vertical-align: middle;
        background: url("./../../assets/imges/backgroundStripe.png") no-repeat 0 -1588px;
      }
      .btnClass {
        color: #333;
        background: url("./../../assets/imges/backgroundStripe.png") no-repeat
          right -1020px;
        padding: 0 5px 0 0;
        white-space: nowrap;
        display: inline-block;
        vertical-align: middle;
        margin-right: 5px;
        i {
          padding-right: 2px;
          padding-left: 28px;
          height: 31px;
          line-height: 30px;
          display: inline-block;
          min-width: 23px;
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -977px;
          cursor: pointer;
        }
      }
      .forward {
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -1225px;
        }
      }
      .download {
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -2761px;
        }
      }
      .comment {
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -1465px;
        }
      }
    }
    .labelBox {
      margin: 25px 0 5px;
      span {
        color: #666;
      }
      ul {
        display: inline-block;
        .labelItem {
          display: inline-block;
          cursor: pointer;
          padding: 0 10px;
          text-shadow: 0 1px #fdfdfd;
          margin: 0px 10px 3px 0;
          border-radius: 11px;
          border: 1px solid #ccc;
          color: #777;
          text-align: center;
          line-height: 20px;
          height: 20px;
          background: #f5f5f5;
          font-size: 12px;
        }
      }
    }
    .description {
      color: #666;
      line-height: 18px;
      display: -webkit-box;
      overflow: hidden;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 4;
    }
    .descriptionte {
      color: #666;
      line-height: 18px;
    }
    .openBtn {
      color: #0c73c2;
      float: right;
      i {
        width: 11px;
        margin-left: 3px;
        height: 8px;
        display: inline-block;
        background: url("./../../assets/imges/btnIconTwo.png") no-repeat -65px -520px;
      }
    }
    .PutItAwayBtn {
      color: #0c73c2;
      float: right;
      i {
        width: 11px;
        margin-left: 3px;
        height: 8px;
        display: inline-block;
        background: url("./../../assets/imges/btnIconTwo.png") no-repeat -45px -520px;
      }
    }
  }
}
</style>